<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib prefix="g" uri="/gt-grid"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<g:head datePicker="true"/>
    
<script language="javascript" type="text/javascript">


var dsConfig= {
		fields :[
			{name : 'id'        },
			{name : 'roleNumber'      },
			{name : 'roleName'   },
			{name : 'roleDescription', type: "date"  },
			{name : 'roleStatus'   }
		]
	};

var colsConfig = [ 
                   {
                       id : 'id',
						header : "选择",
						width : 40,
						align : 'center',
						editable: false,
						isCheckColumn:true
			},  
                  { 
                      id : 'roleNumber'     ,
                      header : "角色编号" , 
                      fieldName : 'roleNumber',
                  	  editor: { type :'text' ,validRule : 'R,string' } ,
                  	  inChart :true, 
                  	  chartColor : '66eeaa'
                   },
                         
                  { 
                      id : 'roleName'   ,
                      header : "角色名称" , 
                      fieldName : 'roleName',
                  	  editor: { type :'text' ,validRule : 'R,string' } ,
                  	  inChart :true, 
                  	  chartColor : '66eeaa'
                   },   
                  { 
                      id : 'roleDescription'    ,
                      header : "角色描述" , 
                      fieldName : 'roleDescription',
                      inChart :false, 
                      editor : {  type :"date" ,validRule : ['date'] ,validator : null , format : "yyyy-MM-dd" },
                      chartColor : '66eeaa'
                      
                    } ,   
                    { 
                        id : 'roleStatus'    ,
                        header : "角色状态" , 
                        fieldName : 'roleStatus',
                        editor : { type :'select' ,options : {'0':'禁用', '1':'启用'}  },
            			renderer : GT.Grid.mappingRenderer(  {'0':'禁用', '1':'启用'} , '禁用' )
                      } 
          ]; 

	GT.Observer.subscribe("beforeDelete", function(record,row,grid) {
		alert('f1 received data: '+record);
		return false;
	});

	GT.Observer.subscribe("afterEdit", function(value,record,columnObj,grid) {
		alert('afterEdit received data: '+value);
	});

	GT.Observer.subscribe("dbClick", function(value, record , cell, row,  colNO, rowNO,columnObj,grid) {
		alert('dbClick received data: '+value);
	});

	GT.Observer.subscribe("afterSave", function(respD,isSuccess) {
		if (isSuccess)
			alert(respD.msg||"保存成功");
	});

</head>
<body>
<g:gt-grid id="grid1" dataset="dsConfig" columns="colsConfig"
	loadURL="josn-role-mgr" saveURL="rolemgrsave" remotePaging="true"
	width="700" height="300" pageSize="10" selectRowByCheck="true"
	toolbarContent="nav | goto | pagesize | reload | add del save | state" 
	afterSaveTopics="afterSave"
	/>
</body>
</html>
